package com.cheer.vo;

import com.cheer.entity.StandingBookDocument;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.File;

/**
 * @author cheer
 */
@Data
@Accessors(chain = true)
public class DocumentNumberVO extends DocumentVO {

    private Integer number;

    public static DocumentNumberVO build(StandingBookDocument document, String resourceUrl) {
        DocumentNumberVO documentNumberVO = new DocumentNumberVO();
        documentNumberVO.setUrl(document.getDocUrl());
        documentNumberVO.setName(StringUtils.substringAfterLast(document.getDocUrl(), File.separator));
        documentNumberVO.setLink(resourceUrl + document.getDocUrl());
        documentNumberVO.setNumber(document.getDocType() - 2);
        return documentNumberVO;
    }

}
